package com.example.redis.myJredis;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;

import java.util.LinkedList;
import java.util.List;
import java.util.ResourceBundle;

/**
 * Created by SOAL on 2017/6/2 0002.
 */
public class JredisShareXml {

    public static void main(String[] args) {

        ApplicationContext app =new ClassPathXmlApplicationContext("classpath:application-bean.xml");
        ShardedJedisPool pool= (ShardedJedisPool) app.getBean("shardedJedisPool");

        // 从池中获取一个Jedis对象
        ShardedJedis jedis = pool.getResource();
        String keys = "name4";
        String value = "snowolf4";
        // 删数据
        jedis.del(keys);
        // 存数据
        jedis.set(keys, value);
        // 取数据
        String v = jedis.get(keys);

        System.out.println(v);

        // 释放对象池
        pool.returnResource(jedis);
    }
}
